]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
layout: Use promise to wait for background to load
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 28 Nov 2025 00:13:29 +0000 (01:13 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 1 Dec 2025 18:39:44 +0000 (18:39 +0000)
This allows us to separate the end of the loading operation
from the steps that follow it. We will soon use that to
express the startup animation as a series of (async) steps
instead of a chain of function calls.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3988>

js/ui/layout.js

index 170a5d49688e289f5e19a2a1bdd058fbde363343..4fd23fe3273401d44e872580310d782d524d4f17 100644 (file)
@@ -678,6 +678,7 @@ export const LayoutManager = GObject.registerClass({
         });
         this._systemBackground.add_constraint(constraint);
 
+        const {promise, resolve} = Promise.withResolvers();
         const signalId = this._systemBackground.connect('loaded', () => {
             this._systemBackground.disconnect(signalId);
 
@@ -688,13 +689,17 @@ export const LayoutManager = GObject.registerClass({
             // This helps to prevent us from running the animation
             // when the system is bogged down
             const id = GLib.idle_add(GLib.PRIORITY_LOW, () => {
-                this._systemBackground.show();
-                global.stage.show();
-                this._prepareStartupAnimation().catch(logError);
+                resolve();
                 return GLib.SOURCE_REMOVE;
             });
             GLib.Source.set_name_by_id(id, '[gnome-shell] Startup Animation');
         });
+
+        await promise;
+
+        this._systemBackground.show();
+        global.stage.show();
+        this._prepareStartupAnimation().catch(logError);
     }
 
     // Startup Animations